package com.example.androidlearning.sy3;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.androidlearning.R;

public class LoginViewActivity extends AppCompatActivity {

    private Button loginBtn;
    private Button registerBtn;
    private EditText usernameET;
    private EditText passwordET;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loginview);

        initComponents();
        setListeners();
    }

    private void initComponents(){

        loginBtn = findViewById(R.id.loginBtn);
        registerBtn = findViewById(R.id.register);
        usernameET = findViewById(R.id.usernameET);
        passwordET = findViewById(R.id.passwordET);

    }

    private void setListeners(){
        loginBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(LoginViewActivity.this,"跳到登录页面", Toast.LENGTH_SHORT).show();
            }
        });

        registerBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(LoginViewActivity.this,"账号："+usernameET.getText().toString()+"\n" + "密码："+passwordET.getText().toString(), Toast.LENGTH_SHORT).show();
            }
        });
    }

}
